package chapter7.section2;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

//程序7-4：读取磁盘文件
public class ResourceUse {
	public String readFile(String path) throws IOException {
		try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
			StringBuilder builder = new StringBuilder();
			String str = null;
			while ((str = reader.readLine()) != null) {
				builder.append(str);
				builder.append(String.format("%n"));
			}
			return builder.toString();
		}
	}
}
